<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: BTree&lt; T &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classBTree-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">BTree&lt; T &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>这是B树的实现，内部有一个BTNode作为其结点，BTree实际上就是一个unique_ptr&lt;BTNode&gt; 另外，这个B树是很好的扩展，可以根据传入的T（key）进行不同的处理，只要重载了operator ==，&lt;,&gt;就可以很好的运用了 也可以修改一下search，以及外部结点，就可以变成B+树  
 <a href="classBTree.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="BTree_8h_source.html">BTree.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:abfd9897f4a7450a38b87269cea42e181"><td class="memItemLeft" align="right" valign="top"><a id="abfd9897f4a7450a38b87269cea42e181"></a>
using&#160;</td><td class="memItemRight" valign="bottom"><b>BTNodePtr</b> = std::unique_ptr&lt; BTNode &gt;</td></tr>
<tr class="separator:abfd9897f4a7450a38b87269cea42e181"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a35304054da7f8cab8bb9cf29e480e4bc"><td class="memItemLeft" align="right" valign="top"><a id="a35304054da7f8cab8bb9cf29e480e4bc"></a>
using&#160;</td><td class="memItemRight" valign="bottom"><b>BTNodePosi</b> = BTNode *</td></tr>
<tr class="separator:a35304054da7f8cab8bb9cf29e480e4bc"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a9fc26aa50dd71d0892fe79a5e4fc7db7"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classBTree.html#a9fc26aa50dd71d0892fe79a5e4fc7db7">BTree</a> (int order=3)</td></tr>
<tr class="memdesc:a9fc26aa50dd71d0892fe79a5e4fc7db7"><td class="mdescLeft">&#160;</td><td class="mdescRight">创建一颗度为order的B树  <a href="classBTree.html#a9fc26aa50dd71d0892fe79a5e4fc7db7">More...</a><br /></td></tr>
<tr class="separator:a9fc26aa50dd71d0892fe79a5e4fc7db7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad247a72b7f190d515d268ea9b991ba75"><td class="memItemLeft" align="right" valign="top"><a id="ad247a72b7f190d515d268ea9b991ba75"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>BTree</b> (const <a class="el" href="classBTree.html">BTree</a> &amp;)=delete</td></tr>
<tr class="separator:ad247a72b7f190d515d268ea9b991ba75"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2a3fd1a4079b81a35e9a5df3315fe444"><td class="memItemLeft" align="right" valign="top"><a id="a2a3fd1a4079b81a35e9a5df3315fe444"></a>
<a class="el" href="classBTree.html">BTree</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><b>operator=</b> (const <a class="el" href="classBTree.html">BTree</a> &amp;)=delete</td></tr>
<tr class="separator:a2a3fd1a4079b81a35e9a5df3315fe444"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a56610295adaa49cbb15b2c91b86f6238"><td class="memItemLeft" align="right" valign="top"><a id="a56610295adaa49cbb15b2c91b86f6238"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>order</b> () const</td></tr>
<tr class="separator:a56610295adaa49cbb15b2c91b86f6238"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab8a7c8c8ae2c02583edfacc660fbc0a7"><td class="memItemLeft" align="right" valign="top"><a id="ab8a7c8c8ae2c02583edfacc660fbc0a7"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>size</b> () const</td></tr>
<tr class="separator:ab8a7c8c8ae2c02583edfacc660fbc0a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a08d5aae9839efabbd29314669d28d5b8"><td class="memItemLeft" align="right" valign="top"><a id="a08d5aae9839efabbd29314669d28d5b8"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><b>empty</b> () const</td></tr>
<tr class="separator:a08d5aae9839efabbd29314669d28d5b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae8216bdb6edd418fc5d1444791a382e2"><td class="memItemLeft" align="right" valign="top"><a id="ae8216bdb6edd418fc5d1444791a382e2"></a>
BTNodePosi&#160;</td><td class="memItemRight" valign="bottom"><b>root</b> () const</td></tr>
<tr class="separator:ae8216bdb6edd418fc5d1444791a382e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abef4d3b58f15a705a8160360d2cd60ec"><td class="memItemLeft" align="right" valign="top">BTNodePosi&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classBTree.html#abef4d3b58f15a705a8160360d2cd60ec">search</a> (const T &amp;e)</td></tr>
<tr class="memdesc:abef4d3b58f15a705a8160360d2cd60ec"><td class="mdescLeft">&#160;</td><td class="mdescRight">搜索值为e的结点，返回其地址，如果搜不到则返回nullptr  <a href="classBTree.html#abef4d3b58f15a705a8160360d2cd60ec">More...</a><br /></td></tr>
<tr class="separator:abef4d3b58f15a705a8160360d2cd60ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad0a275883210c05d4af1644f45128f18"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classBTree.html#ad0a275883210c05d4af1644f45128f18">insert</a> (const T &amp;e)</td></tr>
<tr class="memdesc:ad0a275883210c05d4af1644f45128f18"><td class="mdescLeft">&#160;</td><td class="mdescRight">插入key为e的结点，返回True，  <a href="classBTree.html#ad0a275883210c05d4af1644f45128f18">More...</a><br /></td></tr>
<tr class="separator:ad0a275883210c05d4af1644f45128f18"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aff6835ad66ba5115ae28b2c21b328f51"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classBTree.html#aff6835ad66ba5115ae28b2c21b328f51">remove</a> (const T &amp;e)</td></tr>
<tr class="memdesc:aff6835ad66ba5115ae28b2c21b328f51"><td class="mdescLeft">&#160;</td><td class="mdescRight">从BTree树中删除关键码e 真正删除的节点一定是一个叶子节点，即便e的key不是叶子， 我们也可以通过交换并删除它的后继来达到此效果  <a href="classBTree.html#aff6835ad66ba5115ae28b2c21b328f51">More...</a><br /></td></tr>
<tr class="separator:aff6835ad66ba5115ae28b2c21b328f51"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3040e0a49ee348cae331deaf184bc5f2"><td class="memItemLeft" align="right" valign="top"><a id="a3040e0a49ee348cae331deaf184bc5f2"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>size</b> ()</td></tr>
<tr class="separator:a3040e0a49ee348cae331deaf184bc5f2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8f8c4e3af810c4c48e5f17f4831a81ca"><td class="memItemLeft" align="right" valign="top"><a id="a8f8c4e3af810c4c48e5f17f4831a81ca"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>BTree</b> (int _t)</td></tr>
<tr class="separator:a8f8c4e3af810c4c48e5f17f4831a81ca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8535f16ff64c0de5c41d789bb386af7c"><td class="memItemLeft" align="right" valign="top"><a id="a8535f16ff64c0de5c41d789bb386af7c"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>traverse</b> ()</td></tr>
<tr class="separator:a8535f16ff64c0de5c41d789bb386af7c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8e5d2d87a8a1f53110f84772e60eeda0"><td class="memItemLeft" align="right" valign="top"><a id="a8e5d2d87a8a1f53110f84772e60eeda0"></a>
<a class="el" href="classBTreeNode.html">BTreeNode</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>search</b> (int k)</td></tr>
<tr class="separator:a8e5d2d87a8a1f53110f84772e60eeda0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7da804e6d1ec0a11995c39471c903a65"><td class="memItemLeft" align="right" valign="top"><a id="a7da804e6d1ec0a11995c39471c903a65"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>insert</b> (int k)</td></tr>
<tr class="separator:a7da804e6d1ec0a11995c39471c903a65"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9fc1221f58abaeadafd06c3c9c4ec386"><td class="memItemLeft" align="right" valign="top"><a id="a9fc1221f58abaeadafd06c3c9c4ec386"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>remove</b> (int k)</td></tr>
<tr class="separator:a9fc1221f58abaeadafd06c3c9c4ec386"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;class T&gt;<br />
class BTree&lt; T &gt;</h3>

<p>这是B树的实现，内部有一个BTNode作为其结点，BTree实际上就是一个unique_ptr&lt;BTNode&gt; 另外，这个B树是很好的扩展，可以根据传入的T（key）进行不同的处理，只要重载了operator ==，&lt;,&gt;就可以很好的运用了 也可以修改一下search，以及外部结点，就可以变成B+树 </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a9fc26aa50dd71d0892fe79a5e4fc7db7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9fc26aa50dd71d0892fe79a5e4fc7db7">&#9670;&nbsp;</a></span>BTree()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classBTree.html">BTree</a>&lt; T &gt;::<a class="el" href="classBTree.html">BTree</a> </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>order</em> = <code>3</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>创建一颗度为order的B树 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">order</td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ad0a275883210c05d4af1644f45128f18"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad0a275883210c05d4af1644f45128f18">&#9670;&nbsp;</a></span>insert()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classBTree.html">BTree</a>&lt; T &gt;::insert </td>
          <td>(</td>
          <td class="paramtype">const T &amp;&#160;</td>
          <td class="paramname"><em>e</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>插入key为e的结点，返回True， </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">e</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true 插入成功 </dd>
<dd>
false 如果结点已经存在，因为不支持重复插入那么返回false </dd></dl>

</div>
</div>
<a id="aff6835ad66ba5115ae28b2c21b328f51"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aff6835ad66ba5115ae28b2c21b328f51">&#9670;&nbsp;</a></span>remove()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classBTree.html">BTree</a>&lt; T &gt;::remove </td>
          <td>(</td>
          <td class="paramtype">const T &amp;&#160;</td>
          <td class="paramname"><em>e</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>从BTree树中删除关键码e 真正删除的节点一定是一个叶子节点，即便e的key不是叶子， 我们也可以通过交换并删除它的后继来达到此效果 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">e</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true 成功删除返回true </dd>
<dd>
false 找不到结点返回false </dd></dl>

</div>
</div>
<a id="abef4d3b58f15a705a8160360d2cd60ec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abef4d3b58f15a705a8160360d2cd60ec">&#9670;&nbsp;</a></span>search()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classBTree.html">BTree</a>&lt; T &gt;::BTNodePosi <a class="el" href="classBTree.html">BTree</a>&lt; T &gt;::search </td>
          <td>(</td>
          <td class="paramtype">const T &amp;&#160;</td>
          <td class="paramname"><em>e</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>搜索值为e的结点，返回其地址，如果搜不到则返回nullptr </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">e</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>BTree&lt;T&gt;::BTNodePosi </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="BTree_8h_source.html">BTree.h</a></li>
<li>t.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
